package org.zfes.snowier.zbss.xzy.router.behaviour;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.zbss.xzy.biz.behaviour.model.BehaviourRecord;
import org.zfes.snowier.zbss.xzy.biz.behaviour.service.IBehaviourRecordService;
import org.zfes.snowier.core.data.SelectVo;
@Controller 
@RequestMapping("/behaviour")
public class BehaviourRecordController implements BaseController {

	
	@Autowired
	private IBehaviourRecordService behaviourRecordService;
	
	//@RequiresPermissions(value="behaviourRecord:loadBehaviourRecordDataSet",desc="行为记录列表")
    @RequestMapping(value="/loadBehaviourRecordDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadBehaviourRecordDataSet(@RequestBody Map<String,Object> params){
	    DataSet dataSet=  behaviourRecordService.loadBehaviourRecordDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	//@RequiresPermissions(value="behaviourRecord:createBehaviourRecord",desc="行为记录添加")
    @RequestMapping(value="/createBehaviourRecord", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public  @ResponseBody Object createBehaviourRecord(@RequestBody BehaviourRecord behaviourRecord){
		behaviourRecordService.createBehaviourRecord(behaviourRecord);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="behaviourRecord:loadBehaviourRecord",desc="行为记录加载")
    @RequestMapping(value="/loadBehaviourRecord/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadBehaviourRecord(@PathVariable("id")Long id){
		Optional<BehaviourRecord> ops = behaviourRecordService.loadBehaviourRecordById(id);
		return ajaxQuery("behaviourRecord",ops);
    }
	
	//@RequiresPermissions(value="behaviourRecord:updateBehaviourRecord",desc="行为记录更新")
    @RequestMapping(value="/updateBehaviourRecord", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object updateBehaviourRecord(@RequestBody  BehaviourRecord behaviourRecord){
		behaviourRecordService.updateBehaviourRecord(behaviourRecord);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="behaviourRecord:deletBehaviourRecord",desc="行为记录删除")
    @RequestMapping(value="/deleteBehaviourRecord/{id}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object deleteBehaviourRecord(@PathVariable("id")Long id){
		behaviourRecordService.deleteBehaviourRecord(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }


    @RequestMapping(value="/loadBehaviourRecordSelectVo", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    public @ResponseBody  Object loadBehaviourRecordSelectVo(){
		 List<SelectVo>  ops = behaviourRecordService.loadBehaviourRecordSelectVo("");
		return ajaxQuery("selectVo",ops);
    }
    
}